{{template "header" .}}	
	<title>分类</title>
</head>
<body>
{{template "navigation" .}}	
<!--<div class="container" style="margin:150px;width:1000px">-->
<div class="container" style="margin-top:100px">
	<h1>分类列表</h1>
	<form method="GET" action="/category">
		<div class="form-group">
			<label>分类名称</label>
			<input id="category" class="form-control" type="" name="CategoryName" placeholder="请输入分类名称" >
		</div>
		<input type="hidden" name="op" value="add"/>
		<button class="btn-default" type="submit" onclick="return checkinput();">添加</button>
	</form>
	<script type="text/javascript">
		function checkinput(){
			var name = document.getElementById("category");
			if (name.value.length == 0){
				alert("请输入名称");
				return false;
			}

			return true;
		}
	</script>
	<table class="table table-striped">
		<thead>
			<tr>
				<th>编号</th>
				<th>分类</th>
				<th>文章数</th>
				<th>创建时间</th>
				<th>操作</th>
			</tr>
		</thead>
		<tbody>
			{{range .Categorys}}
			<tr>
				<th>{{.Id}}</th>
				<th>
					<a href="/category/view/{{.Id}}">{{.Title}}</a>
				</th>
				<th>{{.TopicCount}}</th>
				<th>{{.CreateTime}}</th>
				<th>
					<a href="/category/mod/{{.Id}}">修改</a>
					<a href="/category/del/{{.Id}}" onclick="return del()">删除</a>
				</th>	
			</tr>
			{{end}}
		</tbody>
	</table>
	<script type="text/javascript">
		function del(){
			if(!confirm("确认要删除该分类以及属于该分类的所有文章？")){
				window.event.returnValue = false;
			}
		}
	</script> 
</div>
</body>
</html>
